package com.macro.mall.demo.config;

import lombok.Data;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @ClassName EsConfig
 * @Description 描述
 * @Author bai
 * @Date 2024/10/15 22:23
 */

@Component
@Data
public class EsConfig {

    @Value("${es.hostname}")
    private String hostname;

    @Value("${es.port}")
    private int port;

    @Value("${es.scheme}")
    private String scheme;

    @Bean
    public RestHighLevelClient restHighLevelClient(){
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(
                                hostname,
                                port,
                                scheme)));

        return restHighLevelClient;
    }


}
